<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>gozerlib.utils.rsslist &mdash; GOZERWAVE v0.1 BETA documentation</title>
    <link rel="stylesheet" href="../../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../../',
        VERSION:     '0.1 BETA',
        COLLAPSE_MODINDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../../_static/jquery.js"></script>
    <script type="text/javascript" src="../../_static/doctools.js"></script>
    <link rel="top" title="GOZERWAVE v0.1 BETA documentation" href="../../index.html" />
    <link rel="next" title="gozerlib.utils.statdict" href="statdict.html" />
    <link rel="prev" title="gozerlib.utils.name" href="name.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../modindex.html" title="Global Module Index"
             accesskey="M">modules</a> |</li>
        <li class="right" >
          <a href="statdict.html" title="gozerlib.utils.statdict"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="name.html" title="gozerlib.utils.name"
             accesskey="P">previous</a> |</li>
        <li><a href="../../index.html">GOZERWAVE v0.1 BETA documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-gozerlib.utils.rsslist">
<h1>gozerlib.utils.rsslist<a class="headerlink" href="#module-gozerlib.utils.rsslist" title="Permalink to this headline">¶</a></h1>
<p>create a list of rss data</p>
<dl class="function">
<dt id="gozerlib.utils.rsslist.gettext">
<tt class="descclassname">gozerlib.utils.rsslist.</tt><tt class="descname">gettext</tt><big>(</big><em>nodelist</em><big>)</big><a class="headerlink" href="#gozerlib.utils.rsslist.gettext" title="Permalink to this definition">¶</a></dt>
<dd>get text data from nodelist</dd></dl>

<dl class="function">
<dt id="gozerlib.utils.rsslist.makersslist">
<tt class="descclassname">gozerlib.utils.rsslist.</tt><tt class="descname">makersslist</tt><big>(</big><em>xlist</em>, <em>nodes</em>, <em>d={}</em><big>)</big><a class="headerlink" href="#gozerlib.utils.rsslist.makersslist" title="Permalink to this definition">¶</a></dt>
<dd>recurse until txt is found</dd></dl>

<dl class="function">
<dt id="gozerlib.utils.rsslist.rsslist">
<tt class="descclassname">gozerlib.utils.rsslist.</tt><tt class="descname">rsslist</tt><big>(</big><em>txt</em><big>)</big><a class="headerlink" href="#gozerlib.utils.rsslist.rsslist" title="Permalink to this definition">¶</a></dt>
<dd>create list of dictionaries with rss data</dd></dl>

<div class="section" id="code">
<h2>code<a class="headerlink" href="#code" title="Permalink to this headline">¶</a></h2>
<div class="highlight-python"><table class="highlighttable"><tr><td class="linenos"><pre> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55</pre></td><td class="code"><div class="highlight"><pre><span class="c"># gozerbot/rsslist.py</span>
<span class="c">#</span>
<span class="c">#</span>

<span class="sd">&quot;&quot;&quot; create a list of rss data &quot;&quot;&quot;</span>

<span class="c">## gozerlib imports</span>

<span class="kn">from</span> <span class="nn">exception</span> <span class="kn">import</span> <span class="n">handle_exception</span>

<span class="c">## basic imports</span>

<span class="kn">import</span> <span class="nn">xml.dom.minidom</span>

<span class="k">def</span> <span class="nf">gettext</span><span class="p">(</span><span class="n">nodelist</span><span class="p">):</span>

    <span class="sd">&quot;&quot;&quot; get text data from nodelist &quot;&quot;&quot;</span>

    <span class="n">result</span> <span class="o">=</span> <span class="s">&quot;&quot;</span>

    <span class="k">for</span> <span class="n">node</span> <span class="ow">in</span> <span class="n">nodelist</span><span class="p">:</span>

        <span class="k">if</span> <span class="n">node</span><span class="o">.</span><span class="n">nodeType</span> <span class="o">==</span> <span class="n">node</span><span class="o">.</span><span class="n">TEXT_NODE</span> <span class="ow">or</span> <span class="n">node</span><span class="o">.</span><span class="n">nodeType</span> <span class="o">==</span> <span class="n">node</span><span class="o">.</span><span class="n">CDATA_SECTION_NODE</span><span class="p">:</span>
            <span class="n">stripped</span> <span class="o">=</span> <span class="n">node</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>

            <span class="k">if</span> <span class="n">stripped</span><span class="p">:</span>
                <span class="n">result</span> <span class="o">+=</span> <span class="n">stripped</span>

    <span class="k">return</span> <span class="n">result</span>

<span class="k">def</span> <span class="nf">makersslist</span><span class="p">(</span><span class="n">xlist</span><span class="p">,</span> <span class="n">nodes</span> <span class="p">,</span> <span class="n">d</span><span class="o">=</span><span class="p">{}):</span>

    <span class="sd">&quot;&quot;&quot; recurse until txt is found &quot;&quot;&quot;</span>

    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">nodes</span><span class="p">:</span>

        <span class="k">if</span> <span class="n">i</span><span class="o">.</span><span class="n">nodeType</span> <span class="o">==</span> <span class="n">i</span><span class="o">.</span><span class="n">ELEMENT_NODE</span><span class="p">:</span>
            <span class="n">dd</span> <span class="o">=</span> <span class="n">d</span><span class="p">[</span><span class="n">i</span><span class="o">.</span><span class="n">nodeName</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
            <span class="n">makersslist</span><span class="p">(</span><span class="n">xlist</span><span class="p">,</span> <span class="n">i</span><span class="o">.</span><span class="n">childNodes</span><span class="p">,</span> <span class="n">dd</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">dd</span><span class="p">:</span>
                <span class="n">xlist</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">dd</span><span class="p">)</span>

        <span class="n">txt</span> <span class="o">=</span> <span class="n">gettext</span><span class="p">(</span><span class="n">i</span><span class="o">.</span><span class="n">childNodes</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">txt</span><span class="p">:</span>
            <span class="n">d</span><span class="p">[</span><span class="n">i</span><span class="o">.</span><span class="n">nodeName</span><span class="p">]</span> <span class="o">=</span> <span class="n">txt</span>
        
<span class="k">def</span> <span class="nf">rsslist</span><span class="p">(</span><span class="n">txt</span><span class="p">):</span>

    <span class="sd">&quot;&quot;&quot; create list of dictionaries with rss data &quot;&quot;&quot;</span>

    <span class="n">dom</span> <span class="o">=</span> <span class="n">xml</span><span class="o">.</span><span class="n">dom</span><span class="o">.</span><span class="n">minidom</span><span class="o">.</span><span class="n">parseString</span><span class="p">(</span><span class="n">txt</span><span class="p">)</span>
    <span class="n">result</span> <span class="o">=</span> <span class="p">[]</span>
    <span class="n">makersslist</span><span class="p">(</span><span class="n">result</span><span class="p">,</span> <span class="n">dom</span><span class="o">.</span><span class="n">childNodes</span><span class="p">)</span>
    <span class="k">return</span> <span class="n">result</span>
</pre></div>
</td></tr></table></div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <h3><a href="../../index.html">Table Of Contents</a></h3>
            <ul>
<li><a class="reference external" href="">gozerlib.utils.rsslist</a><ul>
<li><a class="reference external" href="#code">code</a></li>
</ul>
</li>
</ul>

            <h4>Previous topic</h4>
            <p class="topless"><a href="name.html"
                                  title="previous chapter">gozerlib.utils.name</a></p>
            <h4>Next topic</h4>
            <p class="topless"><a href="statdict.html"
                                  title="next chapter">gozerlib.utils.statdict</a></p>
            <h3>This Page</h3>
            <ul class="this-page-menu">
              <li><a href="../../_sources/gozerlib/utils/rsslist.txt"
                     rel="nofollow">Show Source</a></li>
            </ul>
          <div id="searchbox" style="display: none">
            <h3>Quick search</h3>
              <form class="search" action="../../search.html" method="get">
                <input type="text" name="q" size="18" />
                <input type="submit" value="Go" />
                <input type="hidden" name="check_keywords" value="yes" />
                <input type="hidden" name="area" value="default" />
              </form>
              <p class="searchtip" style="font-size: 90%">
              Enter search terms or a module, class or function name.
              </p>
          </div>
          <script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../modindex.html" title="Global Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="statdict.html" title="gozerlib.utils.statdict"
             >next</a> |</li>
        <li class="right" >
          <a href="name.html" title="gozerlib.utils.name"
             >previous</a> |</li>
        <li><a href="../../index.html">GOZERWAVE v0.1 BETA documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
      &copy; Copyright 2009, Bart Thate.
      Last updated on Nov 14, 2009.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.3.
    </div>
  </body>
</html>